1. Field of the Invention
The present invention relates generally to data transfers to and from memory in a computer system, and more particularly, to a method for vectoring pwrites or preads.
2. Description of the Relevant Art
An application program running on a microprocessor-based digital computer often initiates system calls to services of the operating system (OS). Each system call involves a context switch between the application program and the operating system. Context switches typically require the state of the microprocessor and/or other components of the computer system to be saved before execution of the system service of the operating system. The operating system in turn loads the microprocessor and/or other components of the computer system with information needed to run the system service. Upon completion of the system service, the microprocessor and/or other components of the computer system must be returned to the state it was prior to the context switch. This requires the saved state to be loaded into the microprocessor and/or other computer components before resuming execution of the application program.
It can be appreciated by one of ordinary skill in the art that the overhead associated with each context switch limits performance of an application program running on a microprocessor-based digital computer. It is also appreciated that there is an indirect relationship between the number of system calls during execution of an application program and the overall performance in running the application program. In other words, a greater number of system calls increases the number of context switches which in turn reduces overall performance.
I/O data transfer between memory and disk typically requires one or more system calls, each one of which requires a substantial amount of system overhead. For example, it is not uncommon for an executing application program to generate several requests to transfer data between memory and disk. To further illustrate, an executing application program may generate ten requests to read data from disk. In the prior art, each of the ten read requests required one or more system calls to complete. This is particularly true if each of the ten read requests identifies a distinct destination buffer in memory to receive data. In some database application programs, a pair of system calls (e.g., Iseek and read) is required for each requested read. The Iseek system call positions the disk so that data can be read from a particular sector in the file. The Iseek is needed since the read request may be directed to a sector in the file which may be remote from a previously read sector. The read system call subsequently reads data from the positioned sector of the disk, the read data ultimately being transferred to a destination buffer in memory.
To avoid the substantial overhead associated with two system calls, prior art implements preads and pwrites which combines a Iseek and a read or write. Preads and pwrites are often referred to as-composite system calls. Thus, preads and pwrites employ one system call to transfer data between disk and memory. Preads, for example, contain an offset, an address of the destination buffer in user space, and a number of bytes to be transferred. Although preads and pwrites reduce the number of system calls associated with individual requests for data transfer, each pread and pwrite nonetheless requires an individual system call.
Vector reads (readv) and vector writes (writev) have been employed in the prior art to further reduce overhead associated with data transfers between memory and disk. In readv and writev system calls, a list of read operations or write operations is provided. The operating system uses the list to transfer data between disk and memory. For example, in a writev system call, the write operations causes data to be gathered from various buffers in memory. The gathered data is then transferred to one location on the disk. Likewise, a list of read operations is used in a ready system call by the operating system to gather data from distinct sectors on the disk. The gathered data is then provided to one location in memory. Ready and writev reduce system overhead when data is being transferred, for example, between multiple noncontiguous buffers and a single sector or between multiple noncontiguous sectors and a single buffer. If the data is to be stored in distinct sectors or distinct buffers, however, individual systems calls are required and there is no overhead savings in using vread or vwrite.